package cn.net.xinyi.xs.util;

import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;

import org.springframework.context.i18n.LocaleContextHolder;

import cn.net.xinyi.xs.Constants;

public class PropertyUtil {
	public static String videoServerSetting() {
		Locale locale = LocaleContextHolder.getLocale();
		String videoServer;
		try {
			videoServer = ResourceBundle.getBundle(Constants.BUNDLE_SYSTEM_KEY,
					locale).getString("XSIGHTVIDEOSERVER.SETTING");
		} catch (MissingResourceException mse) {
			videoServer = "-h 192.168.2.5 -p 10090";
		}
		return videoServer;
	}

	public static String imageServerSetting() {
		Locale locale = LocaleContextHolder.getLocale();
		String imageServer;
		try {
			imageServer = ResourceBundle.getBundle(Constants.BUNDLE_SYSTEM_KEY,
					locale).getString("XSIGHTIMAGESERVER.SETTING");
		} catch (MissingResourceException mse) {
			imageServer = "-h 192.168.2.5 -p 10000";
		}
		return imageServer;
	}

	public static String getApplicationResourcesText(String key) {
		Locale locale = LocaleContextHolder.getLocale();
		String text;
		try {
			text = ResourceBundle.getBundle(Constants.BUNDLE_KEY, locale)
					.getString(key);
		} catch (MissingResourceException mse) {
			text = "";
		}
		return text;
	}

	public static String getText(String key) {
		Locale locale = LocaleContextHolder.getLocale();
		String text;
		try {
			text = ResourceBundle.getBundle(Constants.BUNDLE_KEY, locale)
					.getString(key);
		} catch (MissingResourceException mse) {
			text = "";
		}
		return text;
	}

	public static String getSystemText(String key) {
		Locale locale = LocaleContextHolder.getLocale();
		String text;
		try {
			text = ResourceBundle
					.getBundle(Constants.BUNDLE_SYSTEM_KEY, locale).getString(
							key);
		} catch (MissingResourceException mse) {
			text = "";
		}
		return text;
	}
}
